<script type="text/javascript" src="{{base_url("script/admin-planners/product/01_product_function.js")}}"></script>
<div id="tab">
    <ul style="margin-left: 30px;">
        <li class=""><span>Thông tin cơ bản<span></li>

                    <li>Đặc điểm nổi bật</li>
                    <li>Mô tả</li>
                    <li>Album hình</li>
                    <li>Hướng Dẫn</li>
                    </ul>
                    <div class="tab-thong-tin-co-ban">
                        <div style="padding: 20px;width: 876px">
                            <div>
                                <table style="width:874px;padding-right: 2px;" class="">
                                    <tbody>
                                        <tr>
                                            <td style="width: 430px">
                                                <div class="_input-label" labelcolor="red">
                                                    <div class="input">
                                                        <input type="text" id="txt_product_ProductName" placeholder="" value="{{$configs["obj"]['ProductName']}}">
                                                        <input type="hidden" id="txt_product_ProductID" placeholder="" value="{{$configs["obj"]['ProductID']}}">
                                                        <div class="label "><label>Tên Deal <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="space"></td>
                                            <td>
                                                <div class="_input-label" type="select">
                                                    <div class="input" type="select">
                                                        <div class="select">
                                                            <select id="cbx_product_Label">
                                                                <option value="">[---Để Trống---]</option>
                                                                <option value="new"{{if $configs["obj"]['Label']=="new"}}selected=1{{/if}}>Mới</option>
                                                                <option value="buy"{{if $configs["obj"]['Label']=="buy"}}selected=1{{/if}}>Mua Nhiều</option>
                                                                <option value="hot"{{if $configs["obj"]['Label']=="hot"}}selected=1{{/if}}>Nổi Bật</option>
                                                                <option value="discount"{{if $configs["obj"]['Label']=="discount"}}selected=1{{/if}}>Giảm Giá</option>


                                                            </select>
                                                        </div>
                                                        <div class="label eb"><label>Nhãn</label></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="" colspan="3">
                                                <div class="_input-label" labelcolor="red">
                                                    <div class="input">
                                                        <!--                    <input type="text" id="txt_product_url" placeholder="" value="" disabled="1">-->
                                                        <div   style="position: absolute;
                                                               top: 0;
                                                               left: 0;
                                                               right: 0;
                                                               padding: 0;
                                                               margin: 0;
                                                               padding-left: 108px;
                                                               width: 100%;
                                                               border: 1px solid #CCC;
                                                               height: 26px;
                                                               line-height: 26px;
                                                               background: #FAFAFA;"><span>{{base_url("deal")}}</span>/<span id="txt_product_Alias">{{$configs["obj"]['Alias']}}</span></div>
                                                        <div class="label"><label>Alias <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>

                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" style="width: 762px;" id="txt_product_ProductTitle" placeholder="" value="{{$configs["obj"]['ProductTitle']}}">
                                                        <div class="label eb"><label>Tiêu đề <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="position: relative" colspan="3">
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" id="txt_product_Image" placeholder="" value="{{$configs["obj"]['Image']}}">
                                                        <div class="label eb"><label>Hình Ảnh <font color="red">-</font></label></div>
                                                    </div>
                                                    <div class="icon16 hover50 tooltip" style="position: absolute;top:10px;right:8px;cursor: pointer" 
                                                         onclick="BrowseServer( 'Images:/', 'txt_product_Image' );" title="Chọn hình ảnh">
                                                        <img src="{{base_url()}}images/icon/16/folder_explore.png">
                                                    </div>
                                                </div>
                                            </td>
                                            <!--                <td class="space"></td>
                                                            <td style="position: relative">
                                                                <div class="_input-label" type="select">
                                                                <div class="input" type="select">
                                                                    <div class="select">
                                                                        <select id="cbx_product_category">
                                                                            <option value="HTML5 Template">Danh mục</option>
                                            
                                                                        </select>
                                                                    </div>
                                                                    <div class="label eb"><label>Danh Mục</label></div>
                                                                </div>
                                                                </div>
                                                            </td>-->
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <input type="hidden" id="txt_product_Regions" value="{{$configs["obj"]['Regions']}}"/>
                                                <div class="jqx_group id-group-Regions">
                                                    <div class=""><span class="pl0 pr0 pt0 pb0 ml0 mr0 mt0 mb0">Khu Vực <font color="red">-</font></span></div>
                                                    <div>
                                                        {{if is_array($configs["region_list"]) and count($configs["region_list"])>0}}
                                                        {{foreach $configs["region_list"] as $re}}
                                                        <div style="display: inline-block;float: left">
                                                            <div style="margin-top: 10px;" class='jqx_chbre re{{$re["id"]}}'>
                                                                <span class="value">{{$re["name"]}}</span></div>
                                                        </div>
                                                        {{/foreach}}
                                                        {{else}}
                                                        No data to display.
                                                        {{/if}}
                                                        <div class="clear"></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <input type="hidden" id="txt_product_Categorys" value="{{$configs["obj"]['Categorys']}}"/>
                                                <div class="jqx_group id-group-Categorys">
                                                    <div class=""><span class="pl0 pr0 pt0 pb0 ml0 mr0 mt0 mb0">Danh Mục <font color="red">-</font></span></div>
                                                    <div>
                                                        {{if is_array($configs["category_list"]) and count($configs["category_list"])>0}}
                                                        {{foreach $configs["category_list"] as $ca}}
                                                        <div style="display: inline-block;float: left">
                                                            <div style="margin-top: 10px;" class='jqx_chbca ca{{$ca["id"]}}'>
                                                                <span class="value">{{$ca["name"]}}</span></div>
                                                        </div>
                                                        {{/foreach}}
                                                        {{else}}
                                                        No data to display.
                                                        {{/if}}
                                                        <div class="clear"></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="">
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" id="txt_product_Amount" placeholder="" value="{{$configs["obj"]['Amount']}}">
                                                        <div class="label eb"><label>Số lượng <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="space"></td>
                                            <td>
                                                <div class="_input-label hidden">
                                                    <div class="input">
                                                        <input type="text" id="txt_product_UnitsInStock" placeholder="" value="{{$configs["obj"]['UnitsInStock']}}">
                                                        <div class="label eb"><label>Giá Nhập Kho <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" style="width: 320px;" id="txt_product_ReorderLevel" placeholder="" value="{{$configs["obj"]['ReorderLevel']}}">
                                                        <div class="label eb"><label>Đã Bán(ảo) <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="">
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" id="txt_product_UnitPrice" placeholder="" value="{{$configs["obj"]['UnitPrice']}}">
                                                        <div class="label eb"><label>Giá Gốc <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="space"></td>
                                            <td>
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" style="width: 320px;" id="txt_product_Price" placeholder="" value="{{$configs["obj"]['UnitsOnOrder']}}">
                                                        <div class="label eb"><label>Giá Bán <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="">
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" id="txt_product_StartDate" placeholder="" value="{{if isset($configs["obj"]['StartDate'])}}{{date("Y-m-d H:i", strtotime($configs["obj"]['StartDate']))}}{{/if}}">
                                                        <div class="label eb"><label>Ngày Bắt Đầu <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="space"></td>
                                            <td>
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" style="width: 320px;" id="txt_product_EndDate" placeholder="" value="{{if isset($configs["obj"]['EndDate'])}}{{date("Y-m-d H:i", strtotime($configs["obj"]['EndDate']))}}{{/if}}">
                                                        <div class="label eb"><label>Ngày Kết Thúc <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="">
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" id="txt_product_Supplier" placeholder="" value="{{$configs["obj"]['Supplier']}}">
                                                        <div class="label eb"><label>Nhà Cung Cấp</label></div>
                                                    </div>
                                                </div>
                                            </td>
                                            <td class="space"></td>
                                            <td>
                                                <div class="_input-label">
                                                    <div class="input">
                                                        <input type="text" style="width: 320px;" id="txt_product_QuantityPerUnit" placeholder="" value="{{$configs["obj"]['QuantityPerUnit']}}">
                                                        <div class="label eb"><label>Đơn Vị <font color="red">-</font></label></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <div class="input-full">
                                                    <div class="label eb"><label>Tag</label></div>
                                                </div>
                                                <div style="padding:27px 10px 0 0;">
                                                    <textarea class="_s _w100" id="txt_product_Tag" rows="3" cols="103" 
                                                              style="width: 100%;height: 32px;padding-left: 8px">{{$configs["obj"]['Tag']}}</textarea>
                                                </div>

                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3" style="">
                                                <span style="color: blue">Thêm lúc : {{$configs["obj"]['Insert']}}</span>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                    </div>
                    <div class="tab-dac-diem-noi-bat">
                        <div style="padding: 20px;width: 876px">
                            <div>
                                <table style="width:874px;padding-right: 2px;" class="">
                                    <tbody>
                                        <tr>
                                            <td colspan="3">
                                                <div class="input-full">
                                                    <div class="label eb"><label>Điều Kiện Mua Hàng</label></div>
                                                </div>
                                                <div style="padding:27px 10px 0 0;">
                                                    <textarea class="_s _w100 mceNoEditor" id="txt_product_Brief" rows="3" cols="103" 
                                                              style="width: 100%;height: 100px;padding-left: 8px">{{$configs["obj"]['HowToUser']}}</textarea>
                                                </div>

                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">


                                                <div class="input-full">
                                                    <div class="label eb"><label>Đặc điểm nổi bật <font color="red">-</font></label></div>
                                                </div>
                                                <div style="padding:27px 0px 0 0;width: 870px">
                                                    <textarea class="_s _w100 mceNoEditor" id="txt_product_Feature" rows="3" cols="103" 
                                                              style="width: 862px; height: 200px;padding-left: 8px" aria-hidden="true">{{$configs["obj"]['Feature']}}</textarea>
                                                </div>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                    </div>
                    <div class="tab-noi-dung">
                        <div style="padding: 20px;width: 876px">
                            <div>
                                <table style="width:874px;padding-right: 2px;" class="">
                                    <tbody>
                                        <tr>
                                            <td colspan="3">


                                                <div class="input-full">
                                                    <div class="label eb"><label>Nội dung <font color="red">-</font></label></div>
                                                </div>
                                                <div style="padding:27px 10px 0 0;width: 870px">
                                                    <textarea class="_s _w100 mceEditor" id="txt_product_Content" rows="3" cols="103" 
                                                              style="width: 820px; height: 200px;padding-left: 8px" aria-hidden="true">{{$configs["obj"]['Content']}}</textarea>
                                                </div>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                    <div class="tab-album-hinh">
                        <div style="padding: 20px;width: 876px">
                            <div>
                                <div id="txt_product_Album" class="hidden">{{$configs["obj"]['Album']}}</div>
                                <table style="width:874px;padding-right: 2px;" class="">

                                    <tr>
                                        <th>Hình ảnh</th>
                                        <th>Đường Dẫn</th>
                                        <th style="width: 120px">#</th>
                                    </tr>
                                    <tbody id="product-auto-album">
                                        {{if $configs["obj"]["stralbums"]==""}}
                                        <tr>
                                            <td colspan="3">Hiện chưa tạo album hình.</td>
                                        </tr>
                                        {{else}}
                                        {{$configs["obj"]["stralbums"]}}
                                        {{/if}}
                                    </tbody>
                                    <tr style="background-color: #fffafc">
                                        <td colspan="3">Thêm hình vào album ảnh của deal</td>
                                    </tr>
                                    <tr style="background-color: #fffafc">
                                        <td style="position: relative" colspan="2">
                                            <div class="_input-label">
                                                <div class="input">
                                                    <input type="text" id="txt_product_add_album_image" placeholder="" value="">
                                                    <div class="label eb"><label>Hình Ảnh</label></div>
                                                </div>
                                                <div class="icon16 hover50 tooltip" style="position: absolute;top:10px;right:8px;cursor: pointer" 
                                                     onclick="BrowseServer( 'Images:/', 'txt_product_add_album_image' );" title="Chọn hình ảnh">
                                                    <img src="{{base_url()}}images/icon/16/folder_explore.png">
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <input type="button" class="classic-btn" value="Thêm"
                                                   onclick="addAlbum();"
                                                   />
                                        </td>
                                    </tr>
                                    <tr style="background-color: #fafafc">
                                        <td style="position: relative" colspan="3">
                                            <input type="button" class="classic-btn" 
                                                   value="Tự động lấy các hình từ nội dung của deal."
                                                   onclick="AutoGenAlbum();"
                                                   />
                                        </td>
                                    </tr>

                                </table>
                            </div>
                        </div>

                    </div>
                    <div>
                        Hướng Dẫn.<br/>
                        Phần này sẽ được cập nhật sau.

                    </div>
                    </div>
                    <div class="pt8 pb8" id="btn-deal-groupbutton">
                        <input type="button" class="classic-btn pl20 pr20"  id="btn-deal-ok"
                               style="width: auto;padding-left: 20px;padding-right: 20px"
                               value="Kiểm Tra"
                               onclick="makeAlbums();"
                               />
                        <input type="button" class="classic-btn pl20 pr20"  id="btn-deal-ok"
                               style="width: auto;padding-left: 20px;padding-right: 20px"
                               value="Lưu."
                               onclick="DealOk();"
                               />
                        <input type="button" class="classic-btn pl20 pr20" id="btn-deal-cancel"
                               style="width: auto;padding-left: 20px;padding-right: 20px"
                               value="Hủy."
                               onclick="DealCancel();"
                               />

                    </div>
                    <div style="color: red;text-align: center" id="deal-loadding" class="pt8 pb8 hidden">Đang xử lý...</div>
                    <script type="text/javascript">
     var regions= {{json_encode($configs["region_list"])}};
 
 function getRekey(name){
 for(var i=0;i<regions.length;i++){
 if(regions[i].name==name)
     return regions[i].id;
}
return -1;
}
     
var categorys= {{json_encode($configs["category_list"])}};
 
function getCakey(name){
for(var i=0;i<categorys.length;i++){
if( categorys[i].name==name){
return categorys[i].id;
}
//$("#txt_product_brief").val(categorys[3].name)
}
return 0;
}
function CreateElements(){
var theme = 'classic';
$(".jqx_group").jqxExpander({ showArrow: false, toggleMode: 'none', theme: theme });
$('#tab').jqxTabs({ width:920, theme: theme ,keyboardNavigation: false});
        
//create group checkbox authority
// {{if is_array($configs["region_list"]) and count($configs["region_list"])>0}}
// {{foreach $configs["region_list"] as $re}}

$('.jqx_chbre.re{{$re["id"]}}').jqxCheckBox({ 
checked: {{$re["checked"]}},
height: 25,width: '120px', theme:theme });
// {{/foreach}}
// {{/if}}
        
//create group checkbox authority
// {{if is_array($configs["category_list"]) and count($configs["category_list"])>0}}
// {{foreach $configs["category_list"] as $ca}}

$('.jqx_chbca.ca{{$ca["id"]}}').jqxCheckBox({ 
checked: {{$ca["checked"]}},
height: 25,width: '120px', theme:theme });
// {{/foreach}}
// {{/if}}
        
}
var k;
$(document).ready(function () {
CreateDatetimeElement();
CreateElements();
CreateEditorElement();
AddHandleEvents();
});
                    </script>